using System.ComponentModel.DataAnnotations;

namespace Matrix.Configuration.Options
{
    /// <summary>
    /// 服务通用配置选项
    /// </summary>
    public class ServiceCommonOptions
    {
        /// <summary>
        /// 服务名称
        /// </summary>
        [Required]
        [StringLength(100)]
        public string ServiceName { get; set; } = string.Empty;

        /// <summary>
        /// 服务版本
        /// </summary>
        [Required]
        [RegularExpression(@"^\d+\.\d+\.\d+$", ErrorMessage = "Version must be in format x.y.z")]
        public string Version { get; set; } = "1.0.0";

        /// <summary>
        /// 环境标识
        /// </summary>
        [Required]
        public string Environment { get; set; } = "Development";

        /// <summary>
        /// 是否启用链路追踪
        /// </summary>
        public bool EnableTracing { get; set; } = true;

        /// <summary>
        /// 是否启用性能指标
        /// </summary>
        public bool EnableMetrics { get; set; } = true;

        /// <summary>
        /// 日志级别
        /// </summary>
        public string LogLevel { get; set; } = "Information";

        /// <summary>
        /// 验证配置
        /// </summary>
        public void Validate()
        {
            if (string.IsNullOrWhiteSpace(ServiceName))
                throw new ArgumentException("ServiceName is required");

            if (string.IsNullOrWhiteSpace(Version))
                throw new ArgumentException("Version is required");

            if (string.IsNullOrWhiteSpace(Environment))
                throw new ArgumentException("Environment is required");
        }
    }
}